package com.thoughtworks.biblioteca;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import com.thoughtworks.biblioteca.exceptions.IllegalSelectionNumberException;
import com.thoughworks.biblioteca.utils.HelperUtil;

/**
 * Concrete Command. This item is used for checking out books.
 */
public class CheckOutBookItem extends AbstractMenuItem {

    public CheckOutBookItem(String itemName) {
        super(itemName);
    }

    @Override
    public void execute() {
        System.out
                .println(" Please enter the number of the book you wish to checkout: ");
        BufferedReader bufferedReader = new BufferedReader(
                new InputStreamReader(System.in));
        try {
            int selection = HelperUtil.getInput(bufferedReader);
            BookLibrary.getInstance().checkOutBook(selection);
        } catch (IllegalSelectionNumberException e) {
            e.printStackTrace();
        }
    }

}
